package cn.dm.controller;


import cn.dm.common.Dto;
import cn.dm.service.LocalUserService;
import cn.dm.vo.DmUserRegisterVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user/api/p")
public class LoginController {
    private Logger logger= LoggerFactory.getLogger(LoginController.class);
    @Resource
    private LocalUserService localUserService;

    @PostMapping("/code")
    @ResponseBody
    private Dto code(@RequestParam String phone)throws Exception{
            return localUserService.code(phone);
    }

    @PostMapping("/checkEmail")
    @ResponseBody
    private Dto checkCode(@RequestParam String phone)throws Exception{
        return localUserService.checkEmail(phone);
    }

    @PostMapping("/register")
    @ResponseBody
    private Dto register(@RequestBody DmUserRegisterVO dmUserRegisterVO)throws Exception{
        return localUserService.register(dmUserRegisterVO);
    }

    @PostMapping("/login")
    @ResponseBody
    private Dto login(@RequestParam String phone,@RequestParam String password)throws Exception{
        return localUserService.login(phone,password);
    }
}
